#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL col[maxn];
struct Edge{
    LL u,v;
}edge[maxn];
vector<LL>g[maxn];
bool flag=1;
void dfs(LL u,LL fa,LL val){
    col[u]=val;
    if(0==flag) return;
    for(LL i=0;i<g[u].size();i++){
        LL v=g[u][i];
        if(v==fa) continue;
        if(col[v]==-1) dfs(v,u,val^1);
        else if(col[v]==col[u]){
            flag=0;
            return;
        }
    }
}
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  memset(col,-1,sizeof(col));
  LL n,m;cin>>n>>m;
  for(LL i=1;i<=m;i++){
    LL u,v;cin>>u>>v;
    edge[i].u=u;edge[i].v=v;
    g[u].push_back(v);g[v].push_back(u);
  }
  dfs(1,-1,0);
  if(0==flag){
    cout<<"NO"<<"\n";
  }
  else{
    cout<<"YES"<<"\n";
    for(LL i=1;i<=m;i++){
        LL u=edge[i].u;LL v=edge[i].v;
        if(col[u]==0&&col[v]==1){
            cout<<1;
        }
        else if(col[u]==1&&col[v]==0){
            cout<<0;
        }
    }
    cout<<"\n";
  }
return 0;
}
